<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="../taglib.jsp" %>
<%@page isELIgnored="false" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content ="IE=8"/>

<script type="text/javascript" src="../js/comm/jquery.js"></script>
<script type="text/javascript" src="../assets/anychart/js/AnyChart.js"></script>
<script type="text/javascript" src="../assets/anychart/js/AnyChartHTML5.js"></script>
<title><fmt:message key="chart.list" /></title>
</head>
<body>
	<table style="width: 100%; height: 100%;">
		<tr style="height: 50px;">
			<th><fmt:message key="chart.list" /></th>
			<th><div id="paramDiv"></div></th>
		</tr>
		<tr>
			<td style="align: left; width: 200px;">
				<div>
					<ul>
						<c:forEach var="chart" items="${list}">
							<li><a href="#"
								onclick="javascript:viewChart('${chart.chartId}','');">${chart.chartTitle}</a>
							</li>
						</c:forEach>
					</ul>
				</div>
			</td>
			
			<td style="align: center; width: auto; height: 100%;">
			
				<div id="chartDiv" style="height: 100%;">
				</div>
			</td>
		</tr>
	</table>
	<script type="text/javascript" charset="utf-8">
		function viewChart(chartId,params) {
			$("#chartDiv").empty();
			var url = '/biapp-01-cx/chart/viewEditChart?chartId='
					+ chartId+"&params="+params
// 			}
			//<![CDATA[
			var chart = new AnyChart('../assets/anychart/swf/AnyChart.swf', '../assets/anychart/swf/Preloader.swf');
			chart.wMode = 'transparent';
			chart.width = '100%';
			chart.height = '100%';
			chart.setXMLFile(url);
			chart.write("chartDiv");
			
			showParam(chartId);
			
			//]]> 
		}
		
		function showParam(chartId){
			$("#paramDiv").empty();
			$.ajax({
				type : 'POST',
				url : '/biapp-01-cx/chart/chart/getChartParams',
				data : {
					chartId : chartId
				},
				success: function(data){
			        var jsonObj=eval("("+data+")");   
			        $("#paramDiv").append("参数设置 : &nbsp;&nbsp;" );
			        $.each(jsonObj, function (i, item) {
			        	var paramCd=item.paramCd;
			        	var name=item.paramName;
			        	var value=item.defaultValue;
			        	$("#paramDiv").append( name+ " : <input type='text' id='"+paramCd+"' value="+value+" />&nbsp;&nbsp;");
			        }); 
			        
			        $("#paramDiv").append("&nbsp;&nbsp; <input type='button' value='<fmt:message key="button.ok" />' onclick='javascript:updateChart(\""+chartId+"\");'  /> ");
			    },   
			    error: function(text) {}  
				}
			);

		}
		
		function updateChart(id){
			var temp="{";
			var params=""; 
			$(":text").each(function(i) {                
				var id = $(this).attr("id"); 
				var value = $(this).attr("value");
				if(value.indexOf("%") >= 0){
					value = value.replace(/%/g, "<");
				}
				temp += id + "=" + value + ",";
				});
			params = temp + "}";
			viewChart(id, params);
		}
	</script>
</body>